package leetcode;

public class ReverseInteger {

    public int reverse(int x) {
       long ret=0L;
       while(x!=0){
    	   ret=ret*10+x%10;
    	   if(ret>Integer.MAX_VALUE){
    		   return 0;
    	   }
    	   if(ret<Integer.MIN_VALUE){
    		   return 0;
    	   }
    	   x=x/10;
       }
      return (int) ret;    	   
    }
    
    public static void main(String[] args) {
		ReverseInteger r=new ReverseInteger();
		System.out.println(Integer.MAX_VALUE);
		System.out.println(r.reverse(1));
		System.out.println(r.reverse(1534236469));
		System.out.println(r.reverse(-1));
	}
}
